/**
 * Chesney's Fireplace System Includes New Supplier, New Fireplace Item, Supplier and Fireplace Update, 
 * Supplier and Fireplace Reports, Login, main menu and Tutorial.
 * 
 * It also Includes Database connection, Database Extension and the two classes which are MySupplier and My Fireplace.
 *  
 * Copyright (C) Bournemouth University 
 * 
 * @author Ruth Shepperd, Ari Lopez
 * 
 * @version 1.0
 */
package Database;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
/**
* Class MyFireplace.
* This Class create fireplace objects that will contain data from the database
* It has fireplaceID, fireplaceName, description, finish, style, itemPrice,
* stockQuantity and supplierID attributes.
* It also has static attributes that will refer to the above-mentioned attributes
* when an array is created to be passed as a parameter through a constructor method.
* 
* @author Ari Lopez and Ruth Shepperd
* 
* @version 1.0
* 
*/
public class MyFireplace {
	// Attributes
	private String fireplaceID;
	private String fireplaceName;
	private String description;
	private String finish;
	private String style;
	private float itemPrice;
	private int stockQuantity;
	private String supplierID;

	String data[];

	// Giving parameters constants
	private static final int FIREPLACE_ID = 0;
	private static final int FIREPLACE_NAME = 1;
	private static final int DESCRIPTION = 2;
	private static final int FINISH = 3;
	private static final int STYLE = 4;
	private static final int ITEM_PRICE = 5;
	private static final int STOCK_QUANTITY = 6;
	private static final int SUPPLIER_ID = 7;

	/**
	 * Default constructor method for MyFireplace
	 */
	public MyFireplace() {

	}

	/**
	 * Constructor Method to set data for each field in the Database
	 * 
	 * @param data
	 *            Data of each attribute (String Array)
	 */
	public MyFireplace(String[] data) {

		this.data = data;
		this.fireplaceID = data[FIREPLACE_ID];
		this.fireplaceName = data[FIREPLACE_NAME];
		this.description = data[DESCRIPTION];
		this.finish = data[FINISH];
		this.style = data[STYLE];
		itemPrice = Float.valueOf(data[ITEM_PRICE]);
		this.stockQuantity = Integer.valueOf(data[STOCK_QUANTITY]);
		this.supplierID = data[SUPPLIER_ID];
	}

	/**
	 * Get the Fireplace ID
	 * 
	 * @return Fireplace ID (as a String)
	 */
	public String getFireplaceID() {
		return fireplaceID;
	}

	/**
	 * Set the Fireplace ID
	 * 
	 * @param fireplaceID
	 *            The ID of the Fireplace (String)
	 */
	public void setFireplaceID(String fireplaceID) {
		this.fireplaceID = fireplaceID;
	}

	/**
	 * Get the Fireplace Name
	 * 
	 * @return Fireplace Name (as a String)
	 */
	public String getFireplaceName() {
		return fireplaceName;
	}

	/**
	 * Set the Fireplace Name
	 * 
	 * @param fireplaceName
	 *            The name of Fireplace (String)
	 */
	public void setFireplaceName(String fireplaceName) {
		this.fireplaceName = fireplaceName;
	}

	/**
	 * Get the Description
	 * 
	 * @return Description (as a String)
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Set the Description
	 * 
	 * @param description
	 *            The description of the Fireplace (String)
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Get the Finish
	 * 
	 * @return Finish (as a String)
	 */
	public String getFinish() {
		return finish;
	}

	/**
	 * Set the Finish
	 * 
	 * @param finish
	 *            The finish of the Fireplace (String)
	 */
	public void setFinish(String finish) {
		this.finish = finish;
	}

	/**
	 * Get the Style
	 * 
	 * @return Style (as a String)
	 */
	public String getStyle() {
		return style;
	}

	/**
	 * Set the Style
	 * 
	 * @param style
	 *            The style of the Fireplace (String)
	 */
	public void setStyle(String style) {
		this.style = style;
	}

	/**
	 * Get the Item Price
	 * 
	 * @return Item Price (as a float)
	 */
	public float getItemPrice() {
		return itemPrice;
	}

	/**
	 * Set the Item Price
	 * 
	 * @param itemPrice
	 *            The price of Fireplace (Float)
	 */
	public void setItemPrice(float itemPrice) {
		this.itemPrice = itemPrice;
	}

	/**
	 * Get the Stock Quantity
	 * 
	 * @return Stock Quantity (as a int)
	 */
	public int getStockQuantity() {
		return stockQuantity;
	}

	/**
	 * Set the Stock Quantity
	 * 
	 * @param stockQuantity
	 *            The stock quantity of Fireplace (int)
	 */
	public void setStockQuantity(int stockQuantity) {
		this.stockQuantity = stockQuantity;
	}

	/**
	 * Get the Supplier ID
	 * 
	 * @return Supplier ID (as a String)
	 */
	public String getSupplierID() {
		return supplierID;
	}

	/**
	 * Set the Supplier ID
	 * 
	 * @param supplierID
	 *            The ID of the Supplier (String)
	 */
	public void setSupplierID(String supplierID) {
		this.supplierID = supplierID;
	}

	/**
	 * Set the fireplace combobox
	 * 
	 * @param modelCombo
	 * @param fireplace
	 */
	public void populateFireplaceComboBox(DefaultComboBoxModel modelCombo,
			JComboBox fireplace) {
		MyFireplace fireplaces[] = DatabaseExtended.getFireplaces();
		modelCombo = new DefaultComboBoxModel<MyFireplace>();
		// System.out.println("Fireplace Size: " + fireplaces.length);
		for (MyFireplace fi : fireplaces) {
			modelCombo.addElement(fi);
			System.out.println("This is the to string method in supplier"
					+ fi.toString());
		}
		fireplace.setModel(modelCombo);
	}

	/**
	 * Get the Fireplace Name
	 * 
	 * @return Fireplace Name (as a String)
	 */
	@Override
	public String toString() {
		return fireplaceName;
	}
}
